
var n=5;
function jieCheng(n){  //递归函数求阶乘
     var jc=1;
     if(n<=1){
         return jc;
     }else{
       
         jc=n*arguments.callee(n-1);
     }
     return jc;
 } console.log(jieCheng(5))
var sum=0;
for(var i=1;i<=n;i++){
    sum+=jieCheng(i);//调用函数求阶乘，然后用sum存储它们的和
    console.log(i+"的阶乘等于:"+jieCheng(i));//每个数的阶乘
}
console.log("1~"+n+"的阶乘之和等于:"+sum);
